package com.iocup.keybastion.core.client;


import com.iocup.keybastion.context.WebContextHolder;
import com.iocup.keybastion.core.credentials.Credentials;
import com.iocup.keybastion.core.profile.UserProfile;
import com.iocup.keybastion.core.store.CacheStore;
import com.pine.sunflower.core.LifeCycledAdapter;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.util.Optional;

/**
 * @author xyjxust
 * @create 2022/3/2 9:25
 **/
@Slf4j
@Getter
public abstract class BaseClient<T extends Credentials> extends LifeCycledAdapter implements Client<T> {

    @Setter
    protected CacheStore cacheStore;



    @Override
    public Optional<UserProfile> getUserDetail(T credentials, WebContextHolder contextHolder) {
        if (credentials == null) {
            return Optional.empty();
        }
        log.debug("凭证信息：{}", credentials);
        return doGetUserDetail(credentials, contextHolder);
    }

    public abstract Optional<UserProfile> doGetUserDetail(T credentials, WebContextHolder contextHolder);


}
